package com.iteaj.iot.client.mqtt.impl;

import com.iteaj.iot.client.mqtt.message.MqttClientMessage;
import com.iteaj.iot.client.mqtt.message.MqttMessageHead;
import io.netty.handler.codec.mqtt.MqttPublishMessage;
import io.netty.handler.codec.mqtt.MqttQoS;

public class MqttDefaultClientMessage extends MqttClientMessage {

    private MqttDefaultImplProcessor matcher;

    protected MqttDefaultClientMessage(MqttPublishMessage message, MqttDefaultImplProcessor matcher) {
        super(message);
        this.matcher = matcher;
    }

    public MqttDefaultClientMessage(MqttMessageHead head, String topic) {
        super(head, topic);
    }

    public MqttDefaultClientMessage(MqttMessageHead head, MqttQoS qos, String topic) {
        super(head, qos, topic);
    }

    public MqttDefaultClientMessage(MqttMessageHead head, MessageBody body, String topic) {
        super(head, body, topic);
    }

    public MqttDefaultClientMessage(MqttMessageHead head, MessageBody body, MqttQoS qos, String topic) {
        super(head, body, qos, topic);
    }

    @Override
    protected MqttMessageHead doBuild(byte[] payload) {
        return matcher.buildHeader(payload, this);
    }

    public MqttDefaultImplProcessor getMatcher() {
        return matcher;
    }
}
